import { Effect, ImmerReducer, Reducer, Subscription } from 'umi';
import {getTagList} from '../../../services'
export interface IndexModelState {
    tagList:any;
}

export interface IndexModelType {
  namespace: 'tag';
  state: IndexModelState;
  effects: {
    getTagList:Effect;
  };
  reducers: {
    save: Reducer<IndexModelState>;
  };
//   subscriptions: { setup: Subscription };
}

const IndexModel: IndexModelType = {
  namespace: 'tag',

  state: {
    tagList:[]
  },

  effects: {
    *getTagList({payload},{call,put}){
        let res=yield call(getTagList)
        yield put({
            type:'save',
            payload:{
                tagList:res.data
            }
        })
    }
  },
  reducers: {
    save(state, action) {
      return {
        ...state,
        ...action.payload,
      };
    },
  }
};

export default IndexModel;